import {commGet, commPost, commPut, deleteAction} from "@utils/service/index.js";

/**
 * 获取用户角色列表
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function getUserRoleList(data){
    return commGet({
        url: "sys/role/list",
        method: 'get',
        data
    })
}

/**
 * 新增角色
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function addRole(data){
    return commPost({
        url: "/sys/role/add",
        method: 'post',
        data
    })
}

/**
 * 删除单个角色
 * @param url
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function deleteRole(url,data) {
    return deleteAction({
        url: url,
        data
    })
}

/**
 * 编辑角色
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function editRole(data){
    return commPut({
        url:'/sys/role/edit',
        data
    })
}

/**
 * 保存角色权限
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function saveRolePermission(data){
    return commPost({
        url: '/sys/permission/saveRolePermission',
        method: 'post',
        data
    })
}
export function addSysUserRole(data){
    return commPost({
        url: '/sys/user/addSysUserRole',
        method: 'post',
        data
    })
}

/**
 * 同步角色
 * @param data
 * @returns {Promise<unknown extends (null | undefined) ? unknown : (unknown extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : unknown)>}
 */
export function addSyncRole(data){
    return commPost({
        url: '/sys/role/sync',
        method: 'post',
        data
    })
}
